package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealOverViewVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface SetmealMapper {

    @AutoFill(OperationType.INSERT)
    void addSetmeal(Setmeal setmeal);

    List<SetmealVO> page(String name, Integer status, Integer categoryId);

    @AutoFill(OperationType.UPDATE)
    @Update("update setmeal set status = #{status} , update_time = #{updateTime}  , update_user = #{updateUser} where id = #{id}")
    void updateSetmealStatus(Setmeal setmeal);

    SetmealVO getSetmealById(Long id);

    void deleteSetmealById(List<Long> ids);

    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    List<Integer> getStatusById(List<Long> ids);

    List<Setmeal> list(Setmeal setmeal);

    @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long setmealId);

    @Select("select * from setmeal where id = #{setmealId}")
    Setmeal getById(Long setmealId);

    Integer countByMap(Map map);
}
